﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using ModelLayer;
using DbLayer;

namespace WcfLayer
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class WcfFoodAndAllergies : IWcfFoodAndAllergies
    {
        private UserDb userDb;
        private RecipeDb recipeDb;
        private AllergiesDb allergiesDb;
        private ProductDb productDb;

        public WcfFoodAndAllergies()
        {
            userDb = new UserDb();
            recipeDb = new RecipeDb();
            allergiesDb = new AllergiesDb();
            productDb = new ProductDb();
        }
        #region User
        public int InsertUser(User _user)
        {
            return userDb.InsertUser(_user);
        }
        public User GetUser(string _UserPassword)
        {
            return userDb.GetUser(_UserPassword);
        }
        public User GetUserByUserNameAndPassword(string _userName, string _userPassword)
        {
            return userDb.GetUserByUserNameAndPassword(_userName, _userPassword);
        }
        public int UpdateUser(User _user)
        {
            return userDb.UpdateUser(_user);
        }

     

        #endregion

        #region Recipe
        public int InsertRecipe(Recipe _recipe)
        {
            return recipeDb.InsertRecipe(_recipe);
        }
        public List<Recipe> GetRecipeByAllergi(List<Allergies> _allergies)
        {
            return recipeDb.GetRecipeByAllergies(_allergies);
        }
        public Recipe GetRecipeById(int id)
        {
            return recipeDb.GetRecipeById(id);
        }
        public List<Recipe> GetRecipeByType(string _type)
        {
            return recipeDb.GetRecipeByType(_type);
        }
        public List<Recipe> GetRecipeByName(string _name)
        {
            return recipeDb.GetRecipeByName(_name);
        }
        public List<Recipe> GetRecipeByAllergies(List<Allergies> _list)
        {
            return recipeDb.GetRecipeByAllergies(_list);
        }
        public List<Recipe> GetAllergiFriendlyRecipies(List<Allergies> _allergies)
        {
            return recipeDb.GetAllergiFriendlyRecipies(_allergies);
        }
        public List<Recipe> SelectAllRecipe()
        {
            return recipeDb.SelectAllRecipe();
        }

        #endregion

        #region Allergies

        public int InsertAllergies(Allergies _allergies)
        {
            return allergiesDb.InsertAllergies(_allergies);
        }
        public Allergies GetAllergies(string _name)
        {
            return allergiesDb.GetAllergies(_name);
        }
        public Allergies GetAllergiesById(int _id)
        {
            return allergiesDb.GetAllergiesById(_id);
        }
        public List<Allergies> SelectAllAllergies()
        {
            return allergiesDb.SelectAllAllergies();
        }
        public List<Allergies> GetAllegiesFromProduct(int _productId)
        {
            return allergiesDb.GetAllegiesFromProduct(_productId);
        }
        public List<Allergies> GetUserAllergies(User _user)
        {
            return userDb.GetUserAllergies(_user);
        }

        #endregion

        #region Product

        public int InsertProduct(Product _product)
        {
            return productDb.InsertProduct(_product);
        }
        public List<Product> GetProductByName(string _name)
        {
            return productDb.GetProductByName(_name);
        }
        public Product GetExactProductByName(string _name)
        {
            return productDb.GetExactProductByName(_name);
        }
        public List<Product> GetProductByType (string _type)
        {
            return productDb.GetProductByType(_type);
        }
        public List<Product> SelectAllProduct()
        {
            return productDb.SelectAllProduct();
        }
        public List<String> GetProductTypes()
        {
            return productDb.GetProductTypes();
        }
        public List<Product> GetProductByAllergies(List<Allergies> _list)
        {
            return productDb.GetProductByAllergies(_list);
        }
        public List<Product> GetProductByRecipe(Recipe _recipe)
        {
            return productDb.GetProductsByRecipe(_recipe);
        }
        public List<Product>GetRemaningProducts(List<Product> _products)
        {
            return productDb.GetRemaningProducts(_products);
        }
        public List<Product>GetProductByNameAndType(string _name, string _type)
        {
            return productDb.GetProductByNameAndType(_name, _type);
        }
        #endregion

    }
}
